package com.gxa.day2022_07_29_21.homework.order_system_4.dao;

import com.gxa.day2022_07_29_21.homework.order_system_4.model.Order;
import com.gxa.day2022_07_29_21.homework.order_system_4.memory_store.MemoryStore;

import java.util.List;

/**
 * @Description:
 * @Author: zhuiyi
 * @CreatTime: 2022/7/30 15:27
 **/
public class OrderDao {

    /**
     * 查询所有订单
     * @return 定单列表
     */
    public List<Order> getOders(){
        return MemoryStore.orders;
    }

    /**
     * 保存订单
     * @param order
     */
    public void saveOrder(Order order){
        MemoryStore.orders.add(order);
    }
    /**
     * 签收订单
     * @param index
     */
    public void signOrder(int index){
        MemoryStore.orders.get(index).setOrderStatu(1);
    }

    /**
     * 删除订单
     * @param idx
     */
    public void deleteOrder(int idx){
        MemoryStore.orders.remove(idx);
    }
    /**
     * 根据序号查询订单
     */
    public Order getOrderByIndex(int idx){
        Order order = MemoryStore.orders.get(idx);
        return order;
    }
}
